bitkeeper revision 1.1159.1.265 (41796a46qnHwXIMDGBF85CbCyNp6Ng)
authorcl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Fri, 22 Oct 2004 20:15:02 +0000 (20:15 +0000)
committercl349@freefall.cl.cam.ac.uk <cl349@freefall.cl.cam.ac.uk>
Fri, 22 Oct 2004 20:15:02 +0000 (20:15 +0000)
Remove last reboot, last_reboot, lastboot and rebooted.

tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/XendRoot.py
tools/python/xen/xend/server/SrvServer.py

index 44e4b5f5009531c94c94f8c3ab819ccf09911d86..fc53b4de03cea3f097e8e1dd7b85563e1c359490 100644 (file)
@@ -58,9 +58,9 @@ class XendDomain:
         # Table of domain info indexed by domain id.
         self.db = XendDB.XendDB(self.dbpath)
         self.domain_db = self.db.fetchall("")
-        if xroot.get_rebooted():
-            log.info('XendDomain> rebooted: removing all domain info')
-            self.rm_all()
+        # XXXcl maybe check if there's only dom0 if we _really_ need
+        #       to remove the db 
+        # self.rm_all()
         eserver.subscribe('xend.virq', self.onVirq)
         self.initial_refresh()
 
index 8f188b5d69a4382d51681b1516aa182bafb4f9dc..c9cc9a22798678aee4da9e43248b01be0c720c5c 100644 (file)
@@ -16,24 +16,9 @@ eserver = EventServer.instance()
 
 import sxp
 
-def reboots():
-    """Get a list of system reboots from wtmp.
-    """
-    out = os.popen('last reboot', 'r')
-    list = [ x.strip() for x in out if x.startswith('reboot') ]
-    return list
-
-def last_reboot():
-    """Get the last known system reboot.
-    """
-    l = reboots()
-    return (l and l[-1]) or None
-
 class XendRoot:
     """Root of the management classes."""
 
-    lastboot_default = "/var/xen/lastboot"
-
     """Default path to the root of the database."""
     dbroot_default = "/var/xen/xend-db"
 
@@ -56,14 +41,11 @@ class XendRoot:
     components = {}
 
     def __init__(self):
-        self.rebooted = 0
-        self.last_reboot = None
         self.dbroot = None
         self.config_path = None
         self.config = None
         self.logger = None
         self.configure()
-        self.check_lastboot()
         eserver.subscribe('xend.*', self.event_handler)
         #eserver.subscribe('xend.domain.created', self.event_handler)
         #eserver.subscribe('xend.domain.died', self.event_handler)
@@ -87,7 +69,7 @@ class XendRoot:
         return self.components.get(name)
 
     def start(self):
-        eserver.inject('xend.start', self.rebooted)
+        eserver.inject('xend.start', 0)
 
     def _format(self, msg, args):
         if args:
@@ -145,58 +127,11 @@ class XendRoot:
     def event_handler(self, event, val):
         self.logInfo("EVENT> %s %s", str(event), str(val))
 
-    def read_lastboot(self):
-        """Read the lastboot file to determine the time of the last boot.
-        """
-        try:
-            val = file(self.lastboot, 'rb').readlines()[0]
-        except StandardError, ex:
-            self.logWarning('Error reading %s: %s', self.lastboot, str(ex))
-            val = None
-        return val
-
-    def write_lastboot(self, val):
-        """Write the last boot time to the lastboot file.
-        """
-        if not val: return
-        try:
-            fdir = os.path.dirname(self.lastboot)
-            if not os.path.isdir(fdir):
-                os.makedirs(fdir)
-            out = file(self.lastboot, 'wb+')
-            out.write(val)
-            out.close()
-        except IOError, ex:
-            self.logWarning('Error writing %s: %s', self.lastboot, str(ex))
-
-    def check_lastboot(self):
-        """Check if there has been a system reboot since we saved lastboot.
-        """
-        last_val = self.read_lastboot()
-        this_val = last_reboot()
-        if this_val == last_val:
-            self.rebooted = 0
-        else:
-            self.rebooted = 1
-            self.write_lastboot(this_val)
-        self.last_reboot = this_val
-
-    def get_last_reboot(self):
-        """Get the last reboot time as a string.
-        """
-        return self.last_reboot
-
-    def get_rebooted(self):
-        """Get the rebooted flag. The flag is true if the system has
-        been rebooted since xend was last run.
-        """
-        return self.rebooted
-
     def configure(self):
         self.set_config()
         self.configure_logger()
         self.dbroot = self.get_config_value("dbroot", self.dbroot_default)
-        self.lastboot = self.get_config_value("lastboot", self.lastboot_default)
+
 
     def configure_logger(self):
         logfile = self.get_config_value("logfile", self.logfile_default)
index d1aed29c6bb17ef112415b1acb861137f6e91ac8..28ddaa7e484519990bdf0fe6079297f0f88fdb4a 100644 (file)
@@ -41,7 +41,7 @@ def create(port=None, interface=None, bridge=0):
         port = xroot.get_xend_port()
     if interface is None:
         interface = xroot.get_xend_address()
-    if bridge or xroot.rebooted:
+    if bridge:
         Vifctl.network('start')
     root = resource.Resource()
     xend = SrvRoot()